<include file="public/layout" />
<body style="background-color: #FFF; overflow: auto;"> 
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>文章分类</h3>
        <h5>网站文章分类添加与管理</h5>
      </div>
    </div>
  </div>
	<form method="post" class="form-horizontal" id="category_form">
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label><em>*</em>分类名称</label>
        </dt>
        <dd class="opt">
          <input type="text" class="input-txt" name="cat_name" value="{$cat_info.cat_name}">
          <span class="err" id="err_cat_name"></span>
          <p class="notic"></p>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label for="parent_id">上级分类</label>
        </dt>
        <dd class="opt">
            <select class="small form-control" style="width:200px"  tabindex="1" name="parent_id" id="parent_id">
                <option value="0">顶级分类</option>
                <empty name="cat_info[cat_type]">
                {$cat_select}
                </empty>                                 
            </select>        
          <span class="err"></span>
          <p class="notic">如果选择上级分类，那么新增的分类则为被选择上级分类的子分类</p>
        </dd>
      </dl>      
		<dl class="row">
        <dt class="tit">
          <label>导航显示</label>
        </dt>
        <dd class="opt">
          <div class="onoff">
            <label for="article_show1" class="cb-enable <if condition="$cat_info[show_in_nav] eq 1">selected</if>">是</label>
            <label for="article_show0" class="cb-disable <if condition="$cat_info[show_in_nav] eq 0">selected</if>">否</label>
            <input id="article_show1" name="show_in_nav" value="1" type="radio" <if condition="$cat_info[show_in_nav] eq 1"> checked="checked"</if>>
            <input id="article_show0" name="show_in_nav" value="0" type="radio" <if condition="$cat_info[show_in_nav] eq 0"> checked="checked"</if>>
          </div>
          <p class="notic"></p>
        </dd>
      </dl>		       
      <dl class="row">
        <dt class="tit">
          <label for="ac_sort">排序</label>
        </dt>
        <dd class="opt">
          <input type="text" placeholder="排序" name="sort_order" value="{$cat_info.sort_order}" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')">
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
	  <dl class="row">
        <dt class="tit">
          <label for="ac_sort">搜索关键字</label>
        </dt>
        <dd class="opt">
          <input type="text" placeholder="关键字" name="keywords" value="{$cat_info.keywords}" class="input-txt">
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
	    <dl class="row">
        <dt class="tit">
          <label for="ac_sort">搜索描述</label>
        </dt>
        <dd class="opt">
          <input type="text" placeholder="搜索描述" name="cat_desc" value="{$cat_info.cat_desc}" class="input-txt">
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>            
      <div class="bot"><a href="JavaScript:void(0);" onClick="submitForm()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
    </div>
            <input type="hidden" name="act" value="{$act}">
            <input type="hidden" name="cat_id" value="{$cat_info.cat_id}">    
  </form>
</div>
<script>
    function submitForm() {
        $('span.err').hide();
        $.ajax({
            type: "POST",
            url: "{:U('MarriedArticle/categoryHandle')}",
            data: $('#category_form').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
                if (data.status === 1) {
                    layer.msg(data.msg, {icon: 1,time: 1000}, function() {
                        location.href = "{:U('MarriedArticle/categoryList')}";
                    });
                } else if(data.status === 0) {
                    layer.msg(data.msg, {icon: 2,time: 1000});
                    $.each(data.result, function(index, item) {
                        $('#err_' + index).text(item).show();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2,time: 1000});
                }
            }
        });
    }
</script>
</body>
</html>